package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchPipeNetworkMonitor;
import com.ruoyi.system.service.IDispatchPipeNetworkMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管网监控Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchPipeNetworkMonitor")
public class DispatchPipeNetworkMonitorController extends BaseController
{
    @Autowired
    private IDispatchPipeNetworkMonitorService dispatchPipeNetworkMonitorService;

    /**
     * 查询管网监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchPipeNetworkMonitor dispatchPipeNetworkMonitor)
    {
        startPage();
        List<DispatchPipeNetworkMonitor> list = dispatchPipeNetworkMonitorService.selectDispatchPipeNetworkMonitorList(dispatchPipeNetworkMonitor);
        return getDataTable(list);
    }

    /**
     * 导出管网监控列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:export')")
    @Log(title = "管网监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchPipeNetworkMonitor dispatchPipeNetworkMonitor)
    {
        List<DispatchPipeNetworkMonitor> list = dispatchPipeNetworkMonitorService.selectDispatchPipeNetworkMonitorList(dispatchPipeNetworkMonitor);
        ExcelUtil<DispatchPipeNetworkMonitor> util = new ExcelUtil<DispatchPipeNetworkMonitor>(DispatchPipeNetworkMonitor.class);
        util.exportExcel(response, list, "管网监控数据");
    }

    /**
     * 获取管网监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:query')")
    @GetMapping(value = "/{pipeNetworkMonitorId}")
    public AjaxResult getInfo(@PathVariable("pipeNetworkMonitorId") Long pipeNetworkMonitorId)
    {
        return success(dispatchPipeNetworkMonitorService.selectDispatchPipeNetworkMonitorByPipeNetworkMonitorId(pipeNetworkMonitorId));
    }

    /**
     * 新增管网监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:add')")
    @Log(title = "管网监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchPipeNetworkMonitor dispatchPipeNetworkMonitor)
    {
        return toAjax(dispatchPipeNetworkMonitorService.insertDispatchPipeNetworkMonitor(dispatchPipeNetworkMonitor));
    }

    /**
     * 修改管网监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:edit')")
    @Log(title = "管网监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchPipeNetworkMonitor dispatchPipeNetworkMonitor)
    {
        return toAjax(dispatchPipeNetworkMonitorService.updateDispatchPipeNetworkMonitor(dispatchPipeNetworkMonitor));
    }

    /**
     * 删除管网监控
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchPipeNetworkMonitor:remove')")
    @Log(title = "管网监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pipeNetworkMonitorIds}")
    public AjaxResult remove(@PathVariable Long[] pipeNetworkMonitorIds)
    {
        return toAjax(dispatchPipeNetworkMonitorService.deleteDispatchPipeNetworkMonitorByPipeNetworkMonitorIds(pipeNetworkMonitorIds));
    }
}
